//====================================================================================================
// Includes
//====================================================================================================

#include "BossJump.h"

#include "Boss.h"

//====================================================================================================
// Class Definitions
//====================================================================================================

BossJump::BossJump(Boss* pOwner)
	: BossState(pOwner, "Jump")
{
	// Empty
}

//----------------------------------------------------------------------------------------------------

BossJump::~BossJump()
{
	// Empty
}

//----------------------------------------------------------------------------------------------------

void BossJump::Load(int level)
{
	mSprite.Add("boss_idle01.png");
}

//----------------------------------------------------------------------------------------------------

void BossJump::Unload()
{
	mSprite.Unload();
}

//----------------------------------------------------------------------------------------------------

void BossJump::Update(float deltaTime)
{
	// Update sprite
	mSprite.Update(deltaTime);
}

//----------------------------------------------------------------------------------------------------

void BossJump::Render(const SVector2& offset)
{
	const int kTextureWidth = mSprite.GetWidth();
	const int kTextureHeight = mSprite.GetHeight();
	const SVector2 ownerPos(mpOwner->GetPosition());
	const SVector2 renderPos(ownerPos.x - (kTextureWidth * 0.5f), ownerPos.y - kTextureHeight);
	bool facingLeft = mpOwner->IsFacingLeft();
	mSprite.SetPosition(renderPos - offset);
	mSprite.SetFlipH(facingLeft);
	mSprite.Render();
}

//----------------------------------------------------------------------------------------------------

void BossJump::Enter()
{
	mSprite.Play(1.0f, true);
	SVector2 vel(mpOwner->GetVelocity());
	vel.y = -20.0f;
	mpOwner->SetVelocity(vel);
}

//----------------------------------------------------------------------------------------------------

void BossJump::Exit()
{
	mSprite.Stop();
	mSprite.Reset();
}

//----------------------------------------------------------------------------------------------------

SRect BossJump::GetBoundingBox() const
{
	const SVector2 pos(mpOwner->GetPosition());
	return SRect
	(
		pos.x - 16.0f,
		pos.y - 56.0f,
		pos.x + 16.0f,
		pos.y
	);
}